package com.ilxqx.framework.system.strategy.search;

import org.springframework.lang.Nullable;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;

/**
 * 大于条件策略类
 * @author venus
 */
public class GreaterThanConditionStrategy implements ConditionStrategy {

    /**
     * 处理条件构建
     *
     * @param value   被比较值
     * @param path    比较路径（属性）
     * @param builder 条件构建器
     * @return 断言
     */
    @Override
    @Nullable
    @SuppressWarnings("unchecked")
    public Predicate handle(Object value, Path path, CriteriaBuilder builder) {
        if (value instanceof Comparable) {
            return builder.greaterThan(path, (Comparable) value);
        }
        // 不是比较类型，无法构建条件
        return null;
    }

}
